package com.crm.services;

import java.util.List;
import java.util.Map;

import org.hibernate.service.spi.ServiceException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.crm.model.jdao.IOperatorDAO;
import com.crm.model.mdao.OperatorMapper;
import com.crm.model.pojo.CustomerOperator;
import com.github.pagehelper.PageHelper;

/**
 * 操作日志服务类
 * @author Menghui
 *
 */
@Service
public class OperatorServices {
	
	@Autowired
	OperatorMapper oMapper;//操作日志mybatisDAO
	@Autowired
	IOperatorDAO oDao;//操作日志dao
	
	/**
	 * 分页查询操作日志
	 * @param pageNum
	 * @param pageSize
	 * @return
	 * @throws ServiceException
	 */
	public List<Map<String, String>> selectAllOer(int pageNum,int pageSize) throws ServiceException{
		System.out.println("pageNum:"+pageNum+",pageSize:"+pageSize);
		PageHelper.startPage(pageNum, pageSize);
		return oMapper.selectAllOperator();
	}
	
	/**
	 * 添加操作日志
	 * @return 
	 */
	public CustomerOperator insertOper(CustomerOperator operator) {
		boolean flag = false;
		CustomerOperator save = oDao.save(operator);
		if(save!=null) {
			System.out.println("操作日志："+save);
		}
		System.out.println("新增一条操作日志："+save);
		return save;
	}
}
